
import cn.guo.jmw.handlers.LogHandler;
import cn.guo.jmw.impl.CalculatorImp;
import cn.guo.jmw.interfaces.Calculator;

import java.lang.reflect.Proxy;

/**
 * Created by guo on 2015/10/19.
 */
public class DynamicProxy {

    public static void main(String[] args) {
        Calculator cal = new CalculatorImp();
        LogHandler handler = new LogHandler(cal);

        Calculator proxy = (Calculator) Proxy.newProxyInstance(cal.getClass().getClassLoader(), cal.getClass().getInterfaces(), handler);

        proxy.add(1, 1);
    }
}
